How can I calculate the sum of all positive integers less than n? [closed]

Posted by Adrian Godong on Stack Overflow See other posts from Stack Overflow or by Adrian Godong
Published on 2009-08-03T23:07:32Z Indexed on 2010/04/10 13:43 UTC
Read the original article Hit count: 235

Filed under:
|

I have the following function:

f(n) = f(n - 1) + (n - 1)
f(0) = 0
n >= 0

I have n declared on column A, and need the result of f(n) on column B.

I'm trying to find the Excel formula equivalent for this function.

Sample Result:

A | B
--+--
0 | 0

or:

A | B
--+--
1 | 0

or:

A | B
--+--
4 | 6

but never:

A | B
--+--
0 | 0
1 | 0
2 | 1
...

The biggest problem is, I can't simulate the value of f(n - 1). So referencing the previous row like the above example is invalid. I'm almost sure the answer is trivial, I just can't find it.

© Stack Overflow or respective owner

Related posts about excel

Related posts about formula